//*******************************************************************
//  ChanceDeck.java       Authors: Jason M. Campbell
//								   Randall Brunson
//
//  Object that contains a list or "deck" of Chance cards for the
//  Monopoly game.  An array of Strings containing image names will
//  correspond to the actual .jpg images of the same name.
//*******************************************************************

import java.util.*;

public class ChanceDeck
{
	// array to hold Chance card names
	private ArrayList<String> chanceArrayList;
	
	// array containing actual names of the Chance card images (minus the .jpg extension)
	private String[] chanceStringArray = 
		{"back3spaces", "bank50", "boardwalk", "chairman", "go", "gotojail",
		 "illinois", "jailfreechance", "loanmatures", "nearestutility", "nearrailroad", "poortax",
		 "railroad2", "reading", "repairs", "stcharles"};
	
	// number of cards in the deck
	private final int NUM_CHANCE_CARDS = 16;
	
	public ChanceDeck ()
	{
		// create the chanceArrayList
		chanceArrayList = new ArrayList<String>();
		
		// initialize the chanceArrayList by populating it with the
		// string names from the chanceStringArray
		for (String x: chanceStringArray)
			chanceArrayList.add(x);
		
		// shuffle the deck
		shuffleDeck();
	} // end ChanceDeck constructor
	
	// shuffles the ArrayList
	public void shuffleDeck()
	{
		Collections.shuffle(chanceArrayList);
	} // end shuffleDeck
	
	// returns the number of cards in the deck
	public int getNumChanceCards()
	{
		return NUM_CHANCE_CARDS;
	} // end getNumChanceCards
	
	// returns the StringArray
	// (not sure if this is needed)
	public String[] getStringArray()
	{
		return chanceStringArray;
	} // end getStringArray
		
	// copies the StringArray into another String array
	// (not sure if this is needed)
	public void copyStringArray(String[] str)
	{
		for(int i=0; i<NUM_CHANCE_CARDS ; i++)
		{
			str[i] = chanceStringArray[i];
		}
	} // end copyStringArray
	
	// returns the ArrayList
	// (not sure if this is needed)
	public ArrayList<String> getArrayList()
	{
		return chanceArrayList;
	} // end getArrayList
	
	// copies the ArrayList into another ArrayList
	public void copyArrayList(ArrayList<String> list)
	{
		for(int i=0; i<NUM_CHANCE_CARDS ; i++)
		{
			list.add(chanceArrayList.get(i));
		}		
	} // end copyArrayList
	
	// removes first object in the ArrayList and moves
	// it to the end of the list
	public void frontToBack(ArrayList<String> al)
	{
		//System.out.println(al);
		al.add(al.remove(0));
		//System.out.println(al);
	} // end frontToBack
} // end class ChanceDeck
